 /**
 * 逻辑、功能相关描述: <br>
 *
 * @author 付湘辉  <br>
 * 编写日期：2008-8-14  <br>
 */
package com.ce.pms.charge.service;

import java.math.BigDecimal;
import java.util.List;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;

import com.ce.pms.DBUnitTool;
import com.ce.pms.charge.vo.AdjustTransactionVO;
import com.ce.pms.charge.vo.CashieringSearchVO;
import com.ce.pms.charge.vo.HistoryAccountVO;
import com.sitechasia.webx.core.support.Page;

/**
 * 	名称: com.ce.pms.charge.service.TestCashieringServiceImpl <br>
 *
 *
 * @author  付湘辉  <br>
 * Created on： 2008-8-14 <br>
 * @author <br>
 * update on： <br>
 * why: <br>
 */
public class CashieringServiceImplT extends DBUnitTool {
	private static ICashieringService cashieringService;
	private static ITransactionService transactionService;
	@Ignore
	public void testQueryHouseChargeHistoryListByPage() {
		try {
			initCashieringService();
			CashieringSearchVO searchVo = new CashieringSearchVO();
			searchVo.setHouseId(3l);
			Page page=cashieringService.queryHouseChargeHistoryListByPage(searchVo);
			List list = page.getResult();
			System.out.println(list.size());
		} catch (Exception e) {
			dealException(e);
		}
	}

	@Test
	public void testGetEffectiveHouseChargeInfo() {
		try {
			initCashieringService();
			CashieringSearchVO searchVO=new CashieringSearchVO();
			searchVO.setHouseNumber("1-1a");
			Long start = System.currentTimeMillis();
			System.out.println(start);
			//存在的
			Page res = cashieringService.getEffectiveHouseChargeInfo(searchVO);
			Long end = System.currentTimeMillis();
			System.out.println(end);
			System.out.println(end-start);
			Assert.assertNotNull(res);
		} catch (Exception e) {
			dealException(e);
		}
	}

	@Ignore
	public void testGetLastHouseChargeInfo() {
		try {
			initCashieringService();
			CashieringSearchVO searchVO=new CashieringSearchVO();
			searchVO.setHouseNumber("1-1a");
			//存在历史帐户的
			Page res = cashieringService.getLastHouseChargeInfo(searchVO);
			Assert.assertNotNull(res);
		} catch (Exception e) {
			dealException(e);
		}
	}

	@Ignore
	public void testQueryHouseChargeDetailInfo() {
		try {
			initCashieringService();
			CashieringSearchVO searchVO=new CashieringSearchVO();
			searchVO.setHouseId(3l);
			searchVO.setProRightId(2l);
			searchVO.setAccountId(1l);
			HistoryAccountVO hatvo = cashieringService.queryHouseChargeDetailInfo(searchVO);
			Assert.assertNotNull(hatvo);
		} catch (Exception e) {
			dealException(e);
		}
	}

	@Ignore
	public void testInputReliefAccountForHand() {
		try {
			initCashieringService();
			AdjustTransactionVO reliefTransVO = transactionService.getReliefTransByMasterId(1l);
			reliefTransVO.setAccountHouseId(1l);
			reliefTransVO.setSubAccountId(null);
			reliefTransVO.setCreator(1l);
			reliefTransVO.setRemark("减免费用");
			reliefTransVO.setDebit(BigDecimal.valueOf(200l,2));
			AdjustTransactionVO res=cashieringService.inputReliefAccountForHand(reliefTransVO);
			Assert.assertNotNull(res);
		} catch (Exception e) {
			dealException(e);
		}
	}

	@Ignore
	public void testQueryLatefeeBuAccountId() {
		try {
			initCashieringService();
			Long accountId = 3l;
			BigDecimal res = cashieringService.queryLatefeeByAccountId(accountId);
			Assert.assertNotNull(res);
		} catch (Exception e) {
			dealException(e);
		}
	}

	private void initCashieringService(){
		if (cashieringService == null) {
			cashieringService = (ICashieringService)applicationContext.getBean("cashieringService");
		}
		if (transactionService == null) {
			transactionService = (ITransactionService)applicationContext.getBean("transactionService");
		}
	}
}
